
function Socket(){
     this.jude = 0; //用于判断是否连接成功
     this.ws = new WebSocket('ws://192.168.66.62:9501/');
     this.userId = 0;
     this.idArr = [];
     this.ws.onopen =()=>{  //连接成功调用
          console.log('连接成功');
          var data = {class:'Index',action:'userId','content':{'type':'uId'}};
          data = JSON.stringify(data);
          this.ws.send(data);
          this.jude = 1;

     };
     this.message = (func)=>{

          this.ws.onmessage = function (evt){
                    func(evt);

          }
     }

     this.ws.onmessage = (evt)=>{
         console.log(evt);
         var data = JSON.parse(evt.data);
         this.idArr = data.idArr;
         this.userId = data['uId'];
     }

}

export {
     Socket as Socket
}